import React, { useState } from 'react';
import {
  PieChartOutlined, 
} from '@ant-design/icons';
import type { MenuProps } from 'antd';
import {  Layout, Menu, theme } from 'antd';
import { HomeRouters } from '../Router/RouterConfig';
import { RoutherHome } from '../Router/ulits';
import { NavLink, Outlet } from 'react-router-dom';
const {  Content, Sider } = Layout;

type MenuItem = Required<MenuProps>['items'][number];

function getItem(
  label: React.ReactNode,
  key: any,
  icon?: any,
  children?: MenuItem[],
): MenuItem {
  return {
    
      label,
      key,
      icon,
      children
  } as unknown as MenuItem;
}

// const items: MenuItem[] = [
//   getItem('Option 1', '1', <PieChartOutlined />),
//   getItem('Option 2', '2', <DesktopOutlined />),
//   getItem('User', 'sub1', <UserOutlined />, [
//     getItem('Tom', '3'),
//     getItem('Bill', '4'),
//     getItem('Alex', '5'),
//   ]),
//   getItem('Team', 'sub2', <TeamOutlined />, [getItem('Team 1', '6'), getItem('Team 2', '8')]),
//   getItem('Files', '9', <FileOutlined />),
// ];
console.log(HomeRouters);

const Left: React.FC = () => {
  const [collapsed, setCollapsed] = useState(false);
  const {
    token: {   },
  } = theme.useToken();

const menus=(arr:RoutherHome[])=>{
    let temp: MenuItem[]=[]
   arr&& arr.map((item,index)=>{
        temp.push(getItem(<NavLink to={item.path}>{item.title}</NavLink>,item.id, <PieChartOutlined />,menus(item.children as any)))
    }
)
return temp

}


  return (
    <Layout style={{ minHeight: '100vh', background:"#fff"}} >
      <Sider trigger={null} collapsible collapsed={collapsed}  style={{background:"#fff" ,position: "relative",width:"210px",top:"60px",color:"#000"}}>
        <div className="demo-logo-vertical" style={{background:"#fff"}}/>
        <Menu theme="dark" defaultSelectedKeys={['1']} mode="inline" items={menus(HomeRouters)}  style={{background:"#fff",position: "fixed",width:"200px" }} />
      </Sider>
      <Layout>
        <Content style={{ margin: '0 0px' }} >
          <div
            style={{
              padding: 24,
              minHeight: 360,
            //   background: colorBgContainer,
              
              background:"#fff",
              zIndex:99999999,
              marginTop: "60px",
            }}
          >
            <Outlet></Outlet>
          </div>
        </Content>
       
      </Layout>
    </Layout>
  );
};

export default Left;